#!/bin/bash
# ============================================================
# Script Name:    cameraBringup.sh
# Description:    启动AGV系统的相机及视觉识别功能
#                 包括相机驱动、托盘识别和货架识别等功能
# Author:         haibo
# Created Date:   2025-07-24
# Version:        1.0
# Modified Date:  2025-09-10
# Modified By:    haibo
# Modification:   初始版本
# Usage:          ./cameraBringup.sh [日志文件路径]
# Notes:          1. 支持多种相机类型选择
#                 2. 支持托盘和货架识别功能独立配置
#                 3. 需要common.sh公共函数库支持
# ============================================================
source ${HOME}/lgimRobot/bin/common "$@"

main() {
    # 相机驱动
    local camera_type=$(get_ros2_param "code_read_camera.camera_driver.value")
    case "$camera_type" in
        "0") launch_node "P+F相机" ros2 run code_read_camera code_read_camera_node ;;
        "1") launch_node "超级相机" ros2 run code_read_camera camera_super_node ;;
    esac

    # 博升视觉相机
    [ "$(get_ros2_param "code_read_camera.berxel_driver.value")" = "true" ] && \
        launch_node "识别相机" ros2 run berxel_camera berxel_camera_node
    
    # 托盘识别
    [ "$(get_ros2_param "find_rack_center.enablePalletRecognition.value")" = "true" ] && {
        launch_node "识别相机" ros2 run recognition_camera recognition_camera_node
        launch_node "托盘识别" ros2 run agv_rack_recognition agv_rack_recognition_node
    }
    
    # 货架识别
    [ "$(get_ros2_param "find_rack_center.enableShelfRecognition.value")" = "true" ] && \
        launch_node "货架识别" ros2 run agv_shelf_recognition agv_shelf_recognition_node
    
    return 0
}

main